package com.cloud.salon.client.business.controller;

import com.cloud.salon.client.business.service.RecordService;
import com.cloud.salon.common.base.entity.business.Item;
import com.cloud.salon.common.base.response.Res;
import com.cloud.salon.common.base.entity.business.Record;
import com.cloud.salon.common.base.vo.business.PayVO;
import com.cloud.salon.common.base.vo.business.PlaceOrderVO;
import com.cloud.salon.common.base.vo.business.RecordInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 记录管理控制器
 * @Author wolf--LZH
 * @CreateDate 2019/4/10 0010 下午 1:30
 */
@RestController
@RequestMapping("record")
@Api(tags = "订单记录相关接口")
public class RecordController {

    private final String name = "订单记录";

    @Autowired
    private RecordService service;

    @PostMapping("findById")
    @ApiOperation(value="通过id查找一个" + name)
    public Res<Record> findById(@RequestBody Integer id) {
        return service.findById(id);
    }

    @PostMapping("findAll")
    @ApiOperation(value="获取所有的" + name)
    public Res<List<RecordInfoVO>> findAll() {
        return service.findAllInfo();
    }

    @PostMapping("placeOrder")
    @ApiOperation(value="新建一个新的订单记录")
    public Res<Record> placeOrder(@RequestBody PlaceOrderVO placeOrderVO) {
        return service.placeOrder(placeOrderVO);
    }

    @PostMapping("calcTotal")
    @ApiOperation(value="计算一个订单记录的总价")
    public Res<String> calcTotal(@RequestBody PlaceOrderVO placeOrderVO) {
        return service.calcTotal(placeOrderVO);
    }

    @PostMapping("pay")
    @ApiOperation(value="对某订单记录进行支付")
    public Res payForRecord(@RequestBody PayVO payVO) {
        return service.pay(payVO);
    }
}
